<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="app">
			<ul>
				<li @click="changeColor(key)" v-bind:class="{active: key == clickIndex}" v-for="(item,key) in movies">{{item}}</li>
			</ul>
		</div>
		<script type="text/javascript">
			const app = new Vue({
				el: '#app',
				data: {
					movies:['猪猪侠' , '斗罗大陆' , '火影忍者' , '喜洋洋与灰太狼'],
					clickIndex :''
				},
				methods: {
					changeColor: function (key){
						//var s =document.getElementsByTagName("li")[key]
						//s.className ='active'
						this.clickIndex = key
					},
				}
			})
		</script>
		<style type="text/css">
			.active {
				color: crimson;
			}
		</style>
	</body>
</html>
